init python:
    #インポート
    import random
    import csv
    import os
    
    #外部ファイルの読み込み
    arbeit = open(config.gamedir + "/arbeit.csv", 'rU')
    arbeitlist =  []
    arbeitheader = []
    for i, row in enumerate(csv.reader(arbeit)):
        if i == 0: arbeitheader = [cell.decode('utf_8') for cell in row]
        else: arbeitlist.append([cell.decode('utf_8') for cell in row])
        
    lesson = open(config.gamedir + "/lesson.csv", 'rU')
    lessonlist =  []
    lessonheader = []
    for i, row in enumerate(csv.reader(lesson)):
        if i == 0: lessonheader = [cell.decode('utf_8') for cell in row]
        else: lessonlist.append([cell.decode('utf_8') for cell in row])
        
    weaponList = []
    for row in csv.reader(open(config.gamedir + "/weapon.csv", 'rU')):
        weaponList.append([int(cell) if cell.isdigit() else cell.decode('utf_8') for cell in row])

    armorList = []
    for row in csv.reader(open(config.gamedir + "/armor.csv", 'rU')):
        armorList.append([int(cell) if cell.isdigit() else cell.decode('utf_8') for cell in row])
        
    # 画像の設定
    for fname in os.listdir(config.gamedir + '/picture'):
        if fname.endswith(('.jpg', '.png')):
            tag = fname[:-4]
            renpy.image(tag, 'picture/' + fname)    
    
    # ゲーム中で使う変数の定義と初期値設定
    year = 1
    week = 0
    month = (week / 4 + 3) % 12 + 1
    monthweek = week%4+1
    money = 5000
    restcount = 0
    
    hp = 150
    modified_max_hp = 150
    max_hp = 150
    modified_power = 50
    power = 50
    modified_stamina = 30
    stamina = 30
    modified_intelligence = 35
    intelligence = 35
    modified_pretty = 40
    pretty = 40
    modified_sense = 20
    sense = 20
    stress = 0
    type = "normal"
    
    equipWeapon = None
    equipArmor = None

    furniture_bed = None
    furniture_tv = None
    furniture_house = None
    
    equip_dict = {}

    ### 関数等 ###
    # 確認ダイアログの定義
    def confirm(msg, enabled = True):       # msg に与えられた文字列で確認メッセージが表示される
        ui.frame(xalign=0.5,
                 yalign=0.5,
                 #xfill=False,
                 )
        ui.vbox()
        ui.text(msg)
        ui.hbox()
        ui.textbutton("OK", clicked=ui.returns(True) if enabled else None)
        ui.textbutton("キャンセル", clicked=ui.returns(False))
        
        ui.close()
        ui.close()
        return ui.interact(suppress_overlay=True)
        
    # 体調変化による
    def condition():
        if stress > 50:
            renpy.show('pc anger')
        elif modified_max_hp / 2 > hp:
            renpy.show('pc sad')
        elif modified_max_hp == hp and stress == 0:
            renpy.show('pc smile')
        else:
            renpy.show('pc normal')
            
    # 装備の変更
    def change_equip(category, **equip):
        equip_dict[category] = equip
        recalculate()
        
    # ステータス変化
    def change_status(**status):
        global max_hp
        global stamina
        global power
        global intelligence
        global pretty
        global sense
        max_hp = min(max(max_hp + status.get("max_hp", 0), 0), 9999)
        stamina = min(max(stamina + status.get("stamina", 0), 0), 9999)
        power = min(max(power + status.get("power", 0), 0), 9999)
        intelligence = min(max(intelligence + status.get("intelligence", 0), 0), 9999)
        pretty = min(max(pretty + status.get("pretty", 0), 0), 9999)
        sense = min(max(sense + status.get("sense", 0), 0), 9999)
        recalculate()
        
    # ステータスの再計算
    def recalculate():
        global modified_max_hp
        global modified_stamina
        global modified_power
        global modified_intelligence
        global modified_pretty
        global modified_sense
        modified_max_hp = max_hp
        modified_stamina = stamina
        modified_power = power
        modified_intelligence = intelligence
        modified_pretty = pretty
        modified_sense = sense
        for equip in equip_dict.values():
            modified_max_hp += equip["max_hp"]
            modified_stamina += equip["stamina"]
            modified_power += equip["power"]
            modified_intelligence += equip["intelligence"]
            modified_pretty += equip["pretty"]
            modified_sense += equip["sense"]
